<?php 
class Zend_View_Helper_RenderMenu extends Zend_View_Helper_Abstract{
	
	/**
	 * Render admin menu
	 * 
	 * @param unknown $container
	 * @param number $level
	 */
	public function renderMenu($container, $level=0){
		$view = $this->view;
		
		if(!$container->hasPages()) return;
		$ulClass = ($level==0)?"class='nav navbar-nav'":"class='dropdown-menu'";
		?>
		
		<ul <?php echo $ulClass?>>
		<?php foreach($container as $page ){ 
			$class = array();
			$has_pages_icon = "";
			if($page->hasPages()){
				$class[] = "dropdown";
				if($level==0){
					$has_pages_icon = "<b class='caret'></b>";
				}else{
					$has_pages_icon = "<b class='icon-caret-right pull-right'></b>";
				}
			}
			if($page->isActive()){
				$class[] = "active";
			}
			$liClass = "class='".implode(" ", $class)."'";
			$label = $page->getLabel();
			?>
			<li <?php echo $liClass;?> >
				<a class="dropdown-toggle <?php echo $page->getClass();?>" href="<?php echo $page->getHref();?>"> 
					<!-- icon menu -->
					<?php if($page->iconClass){?>
					<i class="<?php echo $page->iconClass;?>"></i> 
					<?php }elseif($page->iconImg){ ?>
					<img alt="<?php echo $page->getLabel();?>" src="<?php echo $page->iconImg; ?>">
					<?php } ?>
					<!-- icon menu -->
					
					<?php echo $view->translate($label); ?>
					<?php echo $has_pages_icon;?>
				</a>
				<?php $this->renderMenu($page,$level+1); ?>
			</li>
			<?php if(isset($page->divider) && $page->divider=='on'){ ?>
			<li class="divider"></li>
			<?php } ?>
		<?php } ?>
		</ul>
		
		<?php
	}
}
?>